package com.duowei.diandan.bean.food;

import com.duowei.diandan.db.entry.Wmlsb;

import java.io.Serializable;
import java.util.List;

public class OrderItem implements Serializable {
    /** 主项(单品、套餐主项) */
    private Wmlsb main;
    /** 单品子项列表(买赠、加价)、套餐子项列表 */
    private List<Wmlsb> childList;

    public OrderItem(Wmlsb main, List<Wmlsb> childList) {
        this.main = main;
        this.childList = childList;
    }

    public Wmlsb getMain() {
        return main;
    }

    public List<Wmlsb> getChildList() {
        return childList;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof OrderItem) {
            OrderItem or = (OrderItem) obj;

            return this.main != null
                    && or.main != null
                    && this.main.equals(or.main)
                    && this.childList != null
                    && or.childList != null
                    && this.childList.containsAll(or.childList)
                    && or.childList.containsAll(this.childList);
        } else {
            return false;
        }
    }
}
